package com.sky.controller.admin;

import com.sky.result.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
public class ShopController {
    public static final String KEY = "shop:status";
//    private RedisTemplate redisTemplate;
    @Autowired
    private StringRedisTemplate redisTemplate;

    /**
     * 修改营业状态
     * @param status
     * @return
     */
    @PutMapping("/{status}")
    public Result updateStartOrStop(@PathVariable Integer status){
        redisTemplate.opsForValue().set(KEY,String.valueOf(status));
        return Result.success();
    }

    @GetMapping("/status")
    public Result selectStatus(){
        String status = redisTemplate.opsForValue().get(KEY );
        return Result.success(Integer.valueOf(status));
    }

}
